import os

def rename_files_in_directory(path):
    """ 重命名路径下所有文件，去掉文件名中的 (1) """
    for root, _, files in os.walk(path):
        for file in files:
            if "(2)" in file:  # 检查文件名是否包含 (1)
                new_name = file.replace("(2)", "")  # 去掉 (1)
                old_path = os.path.join(root, file)
                new_path = os.path.join(root, new_name)
                os.rename(old_path, new_path)  # 重命名文件
                print(f"Renamed: {old_path} -> {new_path}")

# 调用函数，传入路径A
path_A = "/home/champrin/Desktop/record_data/网盘/兵种内录/装甲板数据集/22年装甲板数据集/DATA5500_src/images"  # 替换为路径A
rename_files_in_directory(path_A)
